function [co] = convert_rhombohedral_to_hexagonal(co)
%CONVERT_RHOMBOHEDRAL_TO_HEXAGONAL Summary of this function goes here
%   Detailed explanation goes here

co.Lattice = co.Lattice.convert_rhombohedral_to_hexagonal;

co.Basis = co.Basis.convert_rhombohedral_to_hexagonal;
co.Positions = co.Basis.BasisVectors*co.Lattice.LatticeVectors;
co.Atoms = co.Basis.Atoms;

% 
% rx = co.Positions(:, 1);
% ry = co.Positions(:, 2);
% rz = co.Positions(:, 3);
% 
% hx = (2*rx-ry-rz)/3;
% hy = (rx+ry-2*rz)/3;
% hz = (rx+ry+rz)/3;
% 
% positions = [hx hy hz];
% lengthPositions = size(positions, 1);
% 
% co.Positions = zeros(length(positions)*3, 3);
% add = [0 0 0;
%   2/3 1/3 1/3;
% 1/3 2/3 2/3];
% 
% for i = 1:size(add, 1)
%   co.Positions(lengthPositions*(i-1)+1:i*lengthPositions, :) = ...
%     positions + repmat(add(i, :), lengthPositions, 1);
% end
% 
% co.Atoms = [co.Atoms; co.Atoms; co.Atoms];
% 
% [co.Positions, co.Atoms] = sort_atoms_by_type(co.Positions, co.Atoms);

%co.Basis = co.Basis.convert_rhombohedral_to_hexagonal;
%co.Positions = co.Basis.BasisVectors*co.Lattice.LatticeVectors;
%co.Atoms = co.Basis.Atoms;
co.LatticeVectors = co.Lattice.LatticeVectors;


end